﻿using System.Collections.Generic;
using System.Data;
using Smatime.Web.DAO.SmatimeDatasetTableAdapters;
using Smatime.Web.Models;

namespace Smatime.Web.DAO
{
    public class HistoryIDRepository :
        BaseRepository<HistoryId, SmatimeDataset.HisttoryIdDataTable, HisttoryIdTableAdapter>
    {
        /// <summary>
        ///     get history id by useraccess id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public HistoryId GetHistoryId(long id)
        {
            using (var adapter = new HisttoryIdTableAdapter())
            {
                var list = new List<HistoryId>();
                using (var table = adapter.GetHistoryIdByUserAccessId(id))
                {
                    var row = table.Rows[0];
                    return (HistoryId) (new HistoryId().FromDataRow(row));
                }
            }
        }
    }
}